home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT05.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.3 KB  |  114 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 5                          
  5.                                           
  6.  Draws vertical lines of different colours, and rotates the colours           
  7.  until you hit a key.                                                         
  8.                                           
  9.  Note: Fast colour rotation with many colours causes 'snow' on slower         
  10.        computers.  If this occurs, limit the number of colours you rotate     
  11.        at once.                                                               
  12.                                           
  13.  *** PROJECT ***                                                             
  14.  This program requires the file WGT5_WC.LIB to be linked.
  15.                                           
  16.  *** DATA FILES ***                                                          
  17.  NONE                                                                        
  18.                                WATCOM C++ VERSION 
  19. ==============================================================================
  20. */
  21.  
  22. #include <wgt5.h>
  23.  
  24.  
  25. void main(void)
  26. {
  27.   short y;
  28.   short oldmode;
  29.   color palette[256];
  30.   
  31.   if ( !vgadetected() )
  32.   {
  33.     printf("Error - VGA card required for any WGT program.\n");
  34.     exit (0);
  35.   }
  36.  
  37.   printf ("WGT Example #5\n\n");
  38.   printf ("This program will rotate the color palette in various index positions\n");
  39.   printf ("until you hit a key to end that set. There are 5 sets in this demo.\n");
  40.   printf ("\n\nPress any key to continue.\n");
  41.   getch ();
  42.  
  43.   oldmode = wgetmode ();
  44.   vga256 ();
  45.  
  46.   for (y = 0; y < 64; y++)
  47.     wsetrgb(y, y, y, y, palette);            /* sets first 64 colours to grey */
  48.   for (y = 0; y < 64; y++)
  49.     wsetrgb (y + 64, y, 0, 0, palette);      /* next 64 to red */
  50.   for (y = 0; y < 64; y++)
  51.     wsetrgb (y + 128, 0, y, 0, palette);     /* green */
  52.   for (y = 0; y < 64; y++)
  53.     wsetrgb (y + 192, 0, 0, y, palette);     /* blue */
  54.  
  55.   wsetpalette (0, 255, palette);           /* and finally change them
  56.                           all at once */
  57.  
  58.   for (y = 0; y < 200; y++)             /* draw lines down the screen */
  59.   {
  60.     wsetcolor (y);
  61.     wline (0, y, 319, y);
  62.   }
  63.  
  64.   while (!kbhit ())
  65.   {
  66.     wretrace ();         /* Reduces the amount of snow on slow computers */
  67.     wcolrotate (1, 200, 0, palette);
  68.     wsetpalette (1, 200, palette);
  69.   }
  70.   getch ();
  71.  
  72.   /* Now rotate it the other way */
  73.   while (!kbhit ())
  74.   {
  75.     wretrace ();
  76.     wcolrotate (1, 200, 1, palette);
  77.     wsetpalette (1, 200, palette);
  78.   }
  79.   getch ();
  80.  
  81.   /* Now rotate it in two directions at once. */
  82.   while (!kbhit ())
  83.   {
  84.     wretrace ();
  85.     wcolrotate (1, 100, 1, palette);
  86.     wcolrotate (100, 200, 0, palette);
  87.     wsetpalette (1, 200, palette);
  88.   }
  89.   getch ();
  90.  
  91.   /* Now the middle of the screen. */
  92.   while (!kbhit ())
  93.   {
  94.     wretrace ();
  95.     wcolrotate (66, 134, 1, palette);
  96.     wsetpalette (66, 134, palette);
  97.   }
  98.   getch ();
  99.  
  100.   /* Now mix all the colours up by overlapping rotation areas! */
  101.   while (!kbhit ())
  102.   {
  103.     wretrace ();
  104.     wcolrotate (1, 200, 0, palette);
  105.     wcolrotate (20, 180, 0, palette);
  106.     wcolrotate (40, 160, 0, palette);
  107.     wcolrotate (60, 120, 0, palette);
  108.     wcolrotate (80, 100, 0, palette);
  109.     wsetpalette (1, 200, palette);
  110.   }
  111.   getch ();
  112.   wsetmode (oldmode);
  113. }
  114.